package com.ruoyi.service.ipml;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.mapper.QuestionBankMapper;
import com.ruoyi.pojo.QuestionBank;
import com.ruoyi.service.QuestionBankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class QuestionBankServiceIpml implements QuestionBankService {
    @Autowired
    private QuestionBankMapper questionBankMapper;
    @Override
    public PageInfo<QuestionBank> search(String name) {
         PageHelper.startPage(1, 5);
        List<QuestionBank> questionBanks = questionBankMapper.search(name);
        PageInfo<QuestionBank> pageInfo = new PageInfo<>(questionBanks);
        System.out.println(questionBanks);
        return pageInfo;
    }

    @Override
    public Boolean AddQuestion(QuestionBank questionBank) {
        questionBank.setCreate_date(new Date());
        return questionBankMapper.add(questionBank);
    }

    @Override
    public List<QuestionBank> findByQuestionBankName(String name) {

        List<QuestionBank> questionBanks = questionBankMapper.findByQuestionBankName(name);

        System.out.println(questionBanks);
        return questionBanks;
    }

    @Override
    public Boolean deleteQuestionBank(Integer id) {
        return questionBankMapper.delete(id);
    }

    @Override
    public Boolean updateQuestionBank(Integer id, String bankName, String creator) {
        return questionBankMapper.update(id, bankName, creator);
    }


}
